package tianxiao.web.test.common;

import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import yun.web.cache.CacheCondition;
import yun.web.cache.CacheItf;

import java.util.concurrent.ConcurrentHashMap;

/*------------------------
      author: 张天笑
      date: 2019/3/20
   测试 缓存
-------------------------*/

@Conditional(CacheCondition.class)
@Component
public class HelloCacheImpl implements CacheItf {

    public static ConcurrentHashMap<String, Object> container = new ConcurrentHashMap<String, Object>();

    public void put(String group, Object key, Object value, long expire) {
        container.put(group + " " + key, value);
    }

    public void put(String group, Object key, Object value) {
        container.put(group + " " + key, value);
    }

    public <T> T get(String group, Object key) {
        return (T) container.get(group + " " + key);
    }

    public <T> T remove(String group, Object key) {
        return (T) container.remove(group + " " + key);
    }
}
